<html>
<head>
    <script src="../tma.js"></script>
    <script id="vShader" type="x-shader/x-vertex">
        attribute vec4 a_color;
        attribute vec4 a_position;
        varying vec4 v_color;
        void main() {
            v_color = a_color;
            gl_Position = a_position;
        }
    </script>
    <script id="fShader" type="x-shader/x-fragment">
        precision mediump float;
        varying vec4 v_color;
        void main() {
            gl_FragColor = v_color;
        }
    </script>
    <script>
        tma.onload = function () {
            // Hello Triangle based on OpenGL ES 2.0 Programming Guide §2.
            var screen = new TmaScreen(640, 480, TmaScreen.MODE_3D);
            screen.attachTo(TmaScreen.BODY);

            // Initializes screen.
            screen.fillColor(0.0, 0.0, 1.0, 1.0);

            // Prepares vertices.
            var programObject = screen.createProgram("vShader", "fShader");
            programObject.setAttribute("a_color", [ 1.0, 0.0, 0.0, 1.0 ]);
            var buffer = screen.createBuffer([  0.0,  0.5,
                                               -0.5, -0.5,
                                                0.5, -0.5 ]);
            programObject.setAttributeArray("a_position", buffer, 0, 2, 8);
            programObject.drawArrays(Tma3DScreen.MODE_TRIANGLES, 0, 3);
            screen.flush();
        }
    </script>
</head>
</html>